namespace SharpTalk.Core
{
    using Base;
    using System;
    using System.Runtime.Serialization;
    using System.Globalization;
    using System.Text;

    [DataContract]
    [Serializable]
    public sealed class SimpleMessage 
        : MessageBase<string>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:SharpTalk.Core.SimpleMessage"/> class.
        /// </summary>
        public SimpleMessage()
           : base(Guid.NewGuid())
        {
            IsNotMotd = true;
        }
        
        [DataMember]
        public bool IsNotMotd { get; set; }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        public override string ToString()
        {
            return string.Format(CultureInfo.InvariantCulture,"{0}:{1}", DateTime, Content);
        }
        /// <summary>
        /// Returns an Xml representation of the SimpleMessage
        /// </summary>
        /// <returns></returns>
        public string ToXmlString()
        {
            var sb = new StringBuilder();
                sb.AppendFormat("<Message guid=\"{0:N}\">",this.Guid);
                sb.AppendFormat(CultureInfo.InvariantCulture, "<DateTime>{0:o}</DateTime>", this.DateTime);
                sb.AppendFormat(CultureInfo.InvariantCulture, "<Content>{0}</Content>", this.Content);
                sb.Append("</Message>"); 
            sb.AppendLine();
            return sb.ToString();
        }
    }
}